package com.kingdee.pda.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.kingdee.pda.R;
import com.kingdee.pda.callback.MyOnScrollChangedListener;
import com.kingdee.pda.entity.LocationBalanceRes;
import com.kingdee.pda.ui.widget.CustomHScrollView;
import com.kingdee.pda.util.ViewHolder;

/**
 * Created by dlj
 * DATE 2021/12/12
 * TIME 20:49
 */
public class WarehouseLocationAdapter2 extends AbsBaseAdapter<LocationBalanceRes> {

    private CustomHScrollView customHScrollView;

    public WarehouseLocationAdapter2(Context context, CustomHScrollView customHScrollView) {
        super(context);
        this.customHScrollView = customHScrollView;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = inflater.inflate(R.layout.adapter_item_warehouse_location2, parent, false);
        }
        TextView tv_spuCode = ViewHolder.get(convertView, R.id.tv_spuCode);
        TextView tv_skuCode = ViewHolder.get(convertView, R.id.tv_skuCode);
        TextView tv_stockQty = ViewHolder.get(convertView, R.id.tv_stock_qty);
        TextView tv_occupyQty = ViewHolder.get(convertView, R.id.tv_occupy_qty);
        TextView tv_availableQty = ViewHolder.get(convertView, R.id.tv_available_qty);
        TextView tv_moveInQty = ViewHolder.get(convertView, R.id.tv_move_in_qty);
        TextView tv_owner=ViewHolder.get(convertView,R.id.tv_owner);
        TextView tv_invStatusName=ViewHolder.get(convertView,R.id.tv_invStatusName);

        CustomHScrollView contentScorllView = convertView.findViewById(R.id.h_scrollView);
        customHScrollView.AddOnScrollChangedListener(new MyOnScrollChangedListener(contentScorllView));

        LocationBalanceRes warehouseLocation = getData().get(position);
        tv_spuCode.setText(warehouseLocation.getItemSkuCode()+"");
        tv_skuCode.setText(warehouseLocation.getItemCode()+"");
        tv_stockQty.setText(String.valueOf(warehouseLocation.getBaseqty()));
        tv_occupyQty.setText(String.valueOf(warehouseLocation.getReservoeqty()));
        tv_availableQty.setText(String.valueOf(warehouseLocation.getAvbbaseqty()));
        tv_moveInQty.setText(String.valueOf(warehouseLocation.getPreinbaseqty()));
        tv_owner.setText(warehouseLocation.getOwnerName());
        tv_invStatusName.setText(warehouseLocation.getInvStatusName());

        return convertView;
    }
}
